diff --git a/addtoany.module b/addtoany.module
index 284ea63..8e4e2f3 100644
--- a/addtoany.module
+++ b/addtoany.module
@@ -110,76 +110,64 @@ function addtoany_entity_view(array &$build, EntityInterface $entity, EntityView
         '#bundle' => $entity->bundle(),
         '#theme' => 'addtoany_standard',
       ];
-    }
-  }
-}
 
-/**
- * Implements hook_page_attachments().
- */
-function addtoany_page_attachments(&$page) {
-  $config = \Drupal::config('addtoany.settings');
-
-  // Initial JavaScript.
-  $additional_js = $config->get('additional_js');
-
-  if (\Drupal::moduleHandler()->moduleExists('token')) {
-    $node = \Drupal::routeMatch()->getParameter('node');
-    $data = [];
-    if ($node) {
-      if (is_numeric($node)) {
-        $node = Node::load($node);
+      $build['#attached']['library'][] = 'addtoany/addtoany';
+
+      // Initial JavaScript.
+      $additional_js = $config->get('additional_js');
+
+      if (\Drupal::moduleHandler()->moduleExists('token')) {
+        $node = \Drupal::routeMatch()->getParameter('node');
+        $data = [];
+        if ($node) {
+          if (is_numeric($node)) {
+            $node = Node::load($node);
+          }
+          $data = ['node' => $node];
+          $additional_js = \Drupal::token()->replace($additional_js, $data);
+        }
       }
-      $data = ['node' => $node];
-      $additional_js = \Drupal::token()->replace($additional_js, $data);
-    }
-  }
 
-  $javascript_header = 'window.a2a_config=window.a2a_config||{};'
-    . 'a2a_config.callbacks=[];a2a_config.overlays=[];'
-    . 'a2a_config.templates={};'
-    . $additional_js;
-
-  // Add AddToAny initial JS config.
-  $page['#attached']['html_head'][] = [
-    // The data.
-    [
-      // Add a <script> tag.
-      '#tag' => 'script',
-      // Add JavaScript to the <script> tag.
-      '#value' => Markup::create($javascript_header),
-      // Give weight so it appears after meta tags, etc.
-      '#weight' => 10,
-    ],
-    // Assign a key to reference this HTML <HEAD> element when altering.
-    'addtoany-js',
-  ];
+      $javascript_header = 'window.a2a_config=window.a2a_config||{};'
+        . 'a2a_config.callbacks=[];a2a_config.overlays=[];'
+        . 'a2a_config.templates={};'
+        . $additional_js;
+
+      // Add AddToAny initial JS config.
+      $build['#attached']['html_head'][] = [
+        // The data.
+        [
+          // Add a <script> tag.
+          '#tag' => 'script',
+          // Add JavaScript to the <script> tag.
+          '#value' => Markup::create($javascript_header),
+          // Give weight so it appears after meta tags, etc.
+          '#weight' => 10,
+        ],
+        // Assign a key to reference this HTML <HEAD> element when altering.
+        'addtoany-js',
+      ];
 
-  // Custom CSS.
-  $css = $config->get('additional_css');
-  if (!empty($css)) {
-    // Add AddToAny custom CSS.
-    $page['#attached']['html_head'][] = [
-      // The data.
-      [
-        // Add a <style> tag.
-        '#tag' => 'style',
-        // Add CSS to the <style> tag.
-        '#value' => $css,
-        // Give weight so it appears after meta tags, etc.
-        '#weight' => 10,
-      ],
-      // Assign a key to reference this HTML <HEAD> element when altering.
-      'addtoany-css',
-    ];
-  }
+      // Custom CSS.
+      $css = $config->get('additional_css');
+      if (!empty($css)) {
+        // Add AddToAny custom CSS.
+        $build['#attached']['html_head'][] = [
+          // The data.
+          [
+            // Add a <style> tag.
+            '#tag' => 'style',
+            // Add CSS to the <style> tag.
+            '#value' => $css,
+            // Give weight so it appears after meta tags, etc.
+            '#weight' => 10,
+          ],
+          // Assign a key to reference this HTML <HEAD> element when altering.
+          'addtoany-css',
+        ];
+      }
 
-  // Add module's main library, which includes external AddToAny core JS,
-  // and the module's CSS.
-  // Enable the libraries if the current route is not an admin page.
-  $route = \Drupal::routeMatch()->getRouteObject();
-  if (!\Drupal::service('router.admin_context')->isAdminRoute($route)) {
-    $page['#attached']['library'][] = 'addtoany/addtoany';
+    }
   }
 }
 
diff --git a/src/Plugin/Block/AddToAnyBlock.php b/src/Plugin/Block/AddToAnyBlock.php
index e0f4982..8840d46 100644
--- a/src/Plugin/Block/AddToAnyBlock.php
+++ b/src/Plugin/Block/AddToAnyBlock.php
@@ -21,30 +21,29 @@ class AddToAnyBlock extends BlockBase {
    */
   public function build() {
     $build = [];
-    $node_id = \Drupal::routeMatch()->getParameter('node');
-    if (is_numeric($node_id)) {
-      $node = Node::load($node_id);
+    $node = \Drupal::routeMatch()->getParameter('node');
+    if (is_numeric($node)) {
+      $node = Node::load($node);
     }
 
-    $is_node = isset($node) && $node instanceof NodeInterface ? true : false;
-    $data = $is_node ? addtoany_create_entity_data($node) : addtoany_create_data();
-
-    $build = [
-      '#addtoany_html'              => $data['addtoany_html'],
-      '#link_url'                   => $data['link_url'],
-      '#link_title'                 => $data['link_title'],
-      '#button_setting'             => $data['button_setting'],
-      '#button_image'               => $data['button_image'],
-      '#universal_button_placement' => $data['universal_button_placement'],
-      '#buttons_size'               => $data['buttons_size'],
-      '#theme'                      => 'addtoany_standard',
-      '#cache'                      => [
-        'contexts' => ['url'],
-      ],
-    ];
-
-    if ($is_node) {
-      $build['#addtoany_html'] = \Drupal::token()->replace($data['addtoany_html'], ['node' => $node]);
+    if ($node instanceof NodeInterface) {
+      $data = addtoany_create_entity_data($node);
+      $build = [
+        '#addtoany_html'              => \Drupal::token()->replace($data['addtoany_html'], ['node' => $node]),
+        '#link_url'                   => $data['link_url'],
+        '#link_title'                 => $data['link_title'],
+        '#button_setting'             => $data['button_setting'],
+        '#button_image'               => $data['button_image'],
+        '#universal_button_placement' => $data['universal_button_placement'],
+        '#buttons_size'               => $data['buttons_size'],
+        '#theme'                      => 'addtoany_standard',
+        '#cache'                      => [
+          'contexts' => ['url'],
+        ],
+        '#attached' => [
+          'library' => 'addtoany/addtoany'
+        ],
+      ];
     }
 
     return $build;
diff --git a/src/Plugin/views/field/NodeAddToAnyShare.php b/src/Plugin/views/field/NodeAddToAnyShare.php
index e8c7fc3..74cf32b 100644
--- a/src/Plugin/views/field/NodeAddToAnyShare.php
+++ b/src/Plugin/views/field/NodeAddToAnyShare.php
@@ -37,6 +37,9 @@ class NodeAddToAnyShare extends FieldPluginBase {
         '#universal_button_placement' => $data['universal_button_placement'],
         '#buttons_size'               => $data['buttons_size'],
         '#theme'                      => 'addtoany_standard',
+        '#attached' => [
+          'library' => 'addtoany/addtoany'
+        ],
       ];
     }
   }
